package lbframework.bean.desktopPane;

import javax.swing.JDesktopPane;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

public class LBDesktopPane extends JDesktopPane {

    public Image img;

    public LBDesktopPane() {
        try {
            img = new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/fundo.png")).getImage();
        } catch (Exception e) {
        }
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (img != null) {
            Dimension dimension = this.getSize();

            int tamanho = 0;

            if (dimension.getHeight() < dimension.getWidth()) {
                tamanho = (int) (dimension.getHeight() * .70);
            } else {
                tamanho = (int) (dimension.getWidth() * .70);
            }

            int x = (int) (dimension.getWidth() - tamanho) / 2;
            int y = (int) (dimension.getHeight() - tamanho) / 2;

            g.drawImage(img, x, y, tamanho, tamanho, this);

        } else {
           // g.drawString("Imagem não encontrada", 50, 50);
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();

        jDesktopPane1.setBackground(java.awt.SystemColor.menu);
        jDesktopPane1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        setBackground(java.awt.SystemColor.menu);
        setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        setForeground(new java.awt.Color(0, 0, 0));
        setFont(new java.awt.Font("Tahoma", 0, 11));
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane jDesktopPane1;
    // End of variables declaration//GEN-END:variables
}
